package com.flexfiltering.view.skins
{
	import flash.display.Graphics;
	
	import mx.core.EdgeMetrics;
	import mx.graphics.RectangularDropShadow;
	import mx.skins.Border;

	public class EditorBorder extends Border
	{
		public function EditorBorder()
		{
			super();
		}
		
		private var dropShadow:RectangularDropShadow;
		
		override public function get borderMetrics () : EdgeMetrics
		{
			var bt:Number = getStyle("borderThickness");
			return new EdgeMetrics(bt,bt,bt,bt);
		}
		
		override protected function updateDisplayList(w:Number, h:Number):void
		{
			super.updateDisplayList(w,h);
			
			var g:Graphics = this.graphics;
			
			g.clear();
			
			var cr:Number = getStyle("cornerRadius");
			var brd_color:uint = getStyle("borderColor");
			var brd_alpha:Number = getStyle("borderAlpha");
			var brd_thickness:Number = getStyle("borderThickness");
			var bkg_color:uint = getStyle("backgroundColor");
			var bkg_alpha:Number = getStyle("backgroundColor");
			var hdr_height:Number = getStyle("headerHeight");
			
			drawRoundRect(0,0,w,h,cr,brd_color,brd_alpha);
			
			drawRoundRect( brd_thickness,
						   brd_thickness*2+hdr_height,
						   w-brd_thickness*2,
						   h-brd_thickness*3-hdr_height,
						   cr-brd_thickness,
						   bkg_color,
						   bkg_alpha );
						   
			// Create a RectangularDropShadow object, set its properties,
			// and draw the shadow
			if (!dropShadow)
				dropShadow = new RectangularDropShadow();
			
			dropShadow.distance = 2;
			dropShadow.angle = 45;
			dropShadow.color = 0x000000
			dropShadow.alpha = 0.4;
	
			dropShadow.tlRadius = cr;
			dropShadow.trRadius = cr;
			dropShadow.blRadius = cr;
			dropShadow.brRadius = cr;
	
			dropShadow.drawShadow(graphics, x, y, width, height);
		}
		
	}
}